<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>用户添加</h2>
<hr>
<form id="user-Form">
  <input type="number" name="id" placeholder="请输入用户id"><br>
  <input type="text" name="name" placeholder="请输入用户名"><br>
  <input type="number" name="age" placeholder="请输入用户年龄"><br>
  <input type="text" name="email" placeholder="请输入用户邮箱"><br>
  <button type="button">确认添加</button>
</form>

<script src="js/jquery-3.7.1.min.js"></script>
<script>
  $(function () {
      //ajax:异步请求技术（局部刷新技术）
      $('button').on('click',function () {
          //获取表单数据转换为查询字符串？id=xx&name=xxx&email=xx
          let data = $('#user-Form').serialize()
          $.get('/user/add',data,function(resp){
              if(resp){
                  alert('添加成功')
                  location.href='index.html'
                return
              }
              alert('添加失败')
          })
      })
  })
</script>
</body>
</html>